<div class="row">
<?php
	$cs=Yii::app()->clientScript;
	$baseUrl=$this->module->assetsUrl;
	$cs->registerScriptFile($baseUrl.'/js/systemtool.js',CClientScript::POS_HEAD);
?>
<div class="button-container mb10">
<?php 
    echo Yii::app()->user->checkAccess('area|update')?CHtml::link('增加区域',$this->createUrl('area/update'),array('class'=>'button')):'';
    echo Yii::app()->user->checkAccess('area|cache')?CHtml::link('更新缓存',$this->createUrl('area/cache'),array('class'=>'button ml10')):'';
?>
</div>
<div class="search-container mb10">
<form method="GET" id="form1" enctype="application/x-www-form-urlencoded">
    <table class="search-table">
        <tr>
            <td>名称：</td>
            <td><input type="text" name="name" class="txt" value="<?php echo $params['name'] ?>" style="width: 130px;" /></td>
            <td><input type="submit" class="btn" value="搜索"/><input type="button" class="btn" value="重置" onclick="BtReset();" />   </td>
        </tr>
    </table>             
</form>
</div>
<!--表格数据-->
<?php
//获取字段语言包
$aAttributeLabels = BaseAreaModel::model()->attributeLabels();
?>
<table class="table table-bordered table-striped dataGrid">
        <thead>
            <tr>
                <th style="width: 80px;"><input type="checkbox" class="btn_all" /> <?php echo $aAttributeLabels['area_id'] ?></th>
                <th><?php echo $aAttributeLabels['name'] ?></th>
                <th><?php echo $aAttributeLabels['first_letter'] ?></th>
                <th><?php echo $aAttributeLabels['type'] ?></th>
				<th><?php echo $aAttributeLabels['level'] ?></th>
				<th>操作</th>
            </tr>
        </thead>
        <tbody>	
        <?php $counts = count($list); ?>
        <?php for($i=0; $i<$counts; $i++){?>
            <tr id="<?php echo $list[$i]['fid']?>_<?php echo $list[$i]['area_id']?>">
                <td><input type="checkbox" class="ids" name="ids[]" value="<?php echo $list[$i]['area_id'];?>" /> <?php echo $list[$i]['area_id'];?></td>
                <td>
                <?php if($list[$i]['has_children']){?>
                <img class="treeicon" id="icon_<?php echo $list[$i]['fid'];?>_<?php echo $list[$i]['area_id'];?>" border="0" onClick="systemTool.getSubTree(this,'<?php echo $list[$i]['fid']?>_<?php echo $list[$i]['area_id']?>','<?php echo $this->createUrl('area/getchildren'); ?>' ,'/static/img/menu_plus.gif','/static/img/menu_minus.gif');" style="margin:3px 0px 0px;" src="<?php echo $this->module->assetsUrl ?>/img/menu_plus.gif" />
                <?php }?>  
                &nbsp;<?php echo $list[$i]['name'];?>
                </td>
				<td><?php echo $list[$i]['first_letter']?></td>
				<td>
				<?php if($list[$i]['pid']==-1){
					echo "自治区、直辖市、特别行政区";
				}elseif($list[$i]['pid']==0){
					echo "省";
				}elseif($list[$i]['pid']==-2){
					echo "海外";
				}?>
				</td>
                <td><?php $fidsarr = explode(',', trim($list[$i]['fids'],','));
				echo count($fidsarr)." 级";
				?></td>				
                <td>
                	<?php if(Yii::app()->user->checkAccess('area,update')){?>
                	<a class="edit" href="<?php echo $this->createUrl('area/update', array('id'=>$list[$i]['area_id'])); ?>">编辑</a>
                	<?php }?>
                	<?php 
                        echo Yii::app()->user->checkAccess('area,delete') ?
                             CHtml::link('删除','javascript:void(0);', array('class'=>'delete table-operate-a' ,'url'=>$this->createUrl('area/delete',array('id'=>$list[$i]['area_id'])))) : '';
                	   
                    ?>           
                </td>
            </tr>         
        <?php }?>              
        </tbody>
</table>
<!-- 分页page start -->
<div class="table-bottom-operate">
    <div class="inline pull-left table-operate">
    </div>
    <div class="inline pull-right page">
        <?php $this->widget('LinkPager',array('pages' => $pages)); ?>
    </div>
	
</div>
<!-- 分页page end -->
</div>
<script type="text/javascript">	
	//重置按钮
	function BtReset(){
	    $("#form1").find("input[type='text']").each(function(){
    		$(this).val("");
  		});
	}   
</script>
